package ae.pcfc.cldos.online.common.clddb.dao.provider;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import ae.pcfc.cldos.online.common.clddb.dao.ApplicationStatusDAO;
import ae.pcfc.cldos.online.common.clddb.domain.ApplicationStatus;
import ae.pcfc.cldos.online.common.dao.GenericDAO;

@Repository
public class ApplicationStatusDAOImpl extends GenericDAO implements ApplicationStatusDAO{
	
	/**
	 * @return ApplicationStatus
	 */
	@SuppressWarnings("unchecked")
	public List<ApplicationStatus> findApplicationStatusByType(String statusType){
		DetachedCriteria criteria = DetachedCriteria.forClass(ApplicationStatus.class);
		if(!statusType.equals("ALL")){
			criteria.add(Restrictions.eq(ApplicationStatus.__STATUS_TYPE, statusType).ignoreCase());
		}
		criteria.add(Restrictions.ne(ApplicationStatus.__STATUS_CODE,ApplicationStatus.UNKNOWN_STATUS));
		return (List<ApplicationStatus>)getListByCriteria(criteria);
	}
	
	public ApplicationStatus findById(Long statusCode){
		return findById(ApplicationStatus.class, statusCode);
	}
}
